//--------------Sonic CD Music Selector Script----------------//
//--------Scripted by Christian Whitehead 'The Taxman'--------//
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//

// States
#alias 0	:	MUSICSELECTOR_BLANK
#alias 1	:	MUSICSELECTOR_STOP_MOVE_L
#alias 2	:	MUSICSELECTOR_MOVE_L
#alias 3	:	MUSICSELECTOR_STOP_MOVE_R
#alias 4	:	MUSICSELECTOR_MOVE_R


sub ObjectMain
	switch Object.State
	case MUSICSELECTOR_BLANK
		break

	case MUSICSELECTOR_STOP_MOVE_L
		Object.XPos -= 0xC0000
		TempValue0   = Screen.CenterX
		TempValue0 <<= 16
		if Object.XPos <= TempValue0
			Object.XPos  = TempValue0
			Object.State = MUSICSELECTOR_BLANK
		end if
		break

	case MUSICSELECTOR_MOVE_L
		Object.XPos -= 0xC0000
		if Object.XPos < -0x600000
			TempValue0   = Screen.XSize
			TempValue0  += 192
			TempValue0 <<= 16
			Object.XPos += TempValue0
			Object.State = MUSICSELECTOR_STOP_MOVE_L
			if Object.Frame < 36
				Object.Frame++
			else
				Object.Frame = 0
			end if
		end if
		break

	case MUSICSELECTOR_STOP_MOVE_R
		Object.XPos += 0xC0000
		TempValue0   = Screen.CenterX
		TempValue0 <<= 16
		if Object.XPos >= TempValue0
			Object.XPos = TempValue0
			Object.State = MUSICSELECTOR_BLANK
		end if
		break

	case MUSICSELECTOR_MOVE_R
		Object.XPos += 0xC0000
		TempValue0   = Screen.XSize
		TempValue0  += 96
		TempValue0 <<= 16
		if Object.XPos > TempValue0
			Object.XPos -= TempValue0
			Object.XPos -= 0x600000
			Object.State = MUSICSELECTOR_STOP_MOVE_R
			if Object.Frame > 0
				Object.Frame--
			else
				Object.Frame = 36
			end if
		end if
		break

	end switch
end sub


sub ObjectDraw
	DrawSprite(Object.Frame)
end sub


sub ObjectStartup
	LoadSpriteSheet("DAGarden/Objects.gif")

	SpriteFrame(-49, -4, 98, 8, 1, 577)			// #0 - PPZ
	SpriteFrame(-68, -4, 136, 8, 1, 586)		// #1 - PPZ "G" Mix
	SpriteFrame(-68, -4, 136, 8, 1, 595)		// #2 - PPZ "B" Mix
	switch SaveRam[512]
	case 0
		SpriteFrame(-42, -4, 94, 8, 1, 856)		// #3 - DDZ
		SpriteFrame(-65, -4, 130, 8, 1, 865)	// #4 - DDZ "G" Mix
		SpriteFrame(-65, -4, 130, 8, 1, 874)	// #5 - DDZ "B" Mix
		break
	
	case 1
		SpriteFrame(-42, -4, 84, 8, 1, 883)		// #3 - RRZ
		SpriteFrame(-60, -4, 120, 8, 1, 892)	// #4 - RRZ "G" Mix
		SpriteFrame(-60, -4, 120, 8, 1, 901)	// #5 - RRZ "B" Mix
		break
		
	case 2 //"Relic Ruins". No relic ruins? :(
		SpriteFrame(-35, -4, 70, 8, 1, 910)		// #3 - RRZ
		SpriteFrame(-53, -4, 106, 8, 1, 919)	// #4 - RRZ "G" Mix
		SpriteFrame(-53, -4, 106, 8, 1, 928)	// #5 - RRZ "B" Mix 
		break
		
	end switch
	SpriteFrame(-54, -4, 108, 8, 1, 604)		// #6 - CCZ
	SpriteFrame(-72, -4, 144, 8, 1, 613)		// #7 - CCZ "G" Mix
	SpriteFrame(-72, -4, 144, 8, 1, 622)		// #8 - CCZ "B" Mix
	SpriteFrame(-46, -4, 92, 8, 1, 631)			// #9 - TTZ 
	SpriteFrame(-65, -4, 130, 8, 1, 640)		// #10 - TTZ "G" Mix
	SpriteFrame(-65, -4, 130, 8, 1, 649)		// #11 - TTZ "B" Mix
	switch SaveRam[542]
	case 0
		SpriteFrame(-53, -4, 106, 8, 1, 964)	// #12 - BBZ
		SpriteFrame(-71, -4, 142, 8, 1, 973)	// #13 - BBZ "G" Mix
		SpriteFrame(-71, -4, 142, 8, 1, 982)	// #14 - BBZ "B" Mix
		break
	
	case 1
		SpriteFrame(-46, -4, 92, 8, 1, 937)		// #12 - DDZ
		SpriteFrame(-64, -4, 128, 8, 1, 946)	// #13 - DDZ "G" Mix
		SpriteFrame(-64, -4, 128, 8, 1, 955)	// #14 - DDZ "B" Mix
		break
	end switch

	SpriteFrame(-54, -4, 108, 8, 1, 658)		// #15 - QQZ 
	SpriteFrame(-72, -4, 144, 8, 1, 667)		// #16 - QQZ "G" Mix
	SpriteFrame(-72, -4, 144, 8, 1, 676)		// #17 - QQZ "B" Mix
	SpriteFrame(-55, -4, 110, 8, 1, 685)		// #18 - WWZ
	SpriteFrame(-73, -4, 146, 8, 1, 694)		// #19 - WWZ "G" Mix
	SpriteFrame(-73, -4, 146, 8, 1, 703)		// #20 - WWZ "B" Mix
	SpriteFrame(-61, -4, 122, 8, 1, 712)		// #21 - SSZ
	SpriteFrame(-79, -4, 158, 8, 1, 721)		// #22 - SSZ "G" Mix
	SpriteFrame(-79, -4, 158, 8, 1, 730)		// #23 - SSZ "B" Mix
	SpriteFrame(-59, -4, 118, 8, 1, 739)		// #24 - MMZ
	SpriteFrame(-77, -4, 154, 8, 1, 748)		// #25 - MMZ "G" Mix
	SpriteFrame(-77, -4, 154, 8, 1, 757)		// #26 - MMZ "B" Mix
	SpriteFrame(-38, -4, 76, 8, 1, 766)			// #27 - Final Fever
	SpriteFrame(-46, -4, 92, 8, 1, 775)			// #28 - Little Planet
	SpriteFrame(-33, -4, 66, 8, 1, 784)			// #29 - Game Over
	SpriteFrame(-36, -4, 72, 8, 1, 793)			// #30 - Zone Clear
	SpriteFrame(-18, -4, 36, 8, 1, 802)			// #31 - Boss!!
	SpriteFrame(-37, -4, 74, 8, 1, 811)			// #32 - Invincible!!
	SpriteFrame(-30, -4, 60, 8, 1, 820)			// #33 - Speed Up!!
	SpriteFrame(-18, -4, 36, 8, 1, 829)			// #34 - Title
	SpriteFrame(-45, -4, 90, 8, 1, 838)			// #35 - Special Stage
	SpriteFrame(-40, -4, 81, 8, 1, 847)			// #36 - Time Attack
end sub


// ========================
// Editor Subs
// ========================

sub RSDKDraw
	DrawSprite(0)
end sub


sub RSDKLoad
	LoadSpriteSheet("DAGarden/Objects.gif")
	SpriteFrame(-49, -4, 98, 8, 1, 577) // PPZ text

	SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
end sub
